{include file='common/head'}
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">演示</a>
        <a>
          <cite>管理员列表</cite></a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <xblock>
        <button class="layui-btn" onclick="x_admin_show('添加管理员','{:url(\'admin/guanli/insert\')}')"><i class="layui-icon"></i>添加管理员</button>
    </xblock>
    <table class="layui-table" >
        <thead>
        <tr>
            <th>NO</th>
            <th>昵称</th>
            <th>用户名</th>
            <th>手机号</th>
            <th>状态</th>
            <th >操作</th>
        </tr>
        </thead>
        <tbody>
        {volist name="guanli" id="guanli"}
        <tr>
            <td>{$key+1}</td>
            <td>{$guanli.jname}</td>
            <td>{$guanli.gname}</td>
            <td>{$guanli.phone}</td>
            <td>{if $guanli.state==1}正常{else/}冻结{/if}</td>
            <td class="td-manage">
                <a title="删除" onclick="member_del(this,'{$guanli.zid}')" href="javascript:;">
                    <i class="layui-icon">&#xe640;</i>删除
                </a>
                <a title="编辑" onclick="banner_edit(this,'{$guanli.zid}')" attr_id='' href="javascript:;">
                    <i class="layui-icon">&#xe642;</i>编辑
                </a>
                {if $guanli.state==1}
                <a title="禁用" onclick="member_jin(this,'{$guanli.zid}')" href="javascript:;">
                    <i class="layui-icon">&#xe642;</i>禁用
                </a>{else/}
                <a title="启用" onclick="member_qi(this,'{$guanli.zid}')" href="javascript:;">
                    <i class="layui-icon">&#xe642;</i>启用
                </a>{/if}
            </td>
        </tr>
        {/volist}
        </tbody>
    </table>
    <div class="page">
        <div>
        </div>
    </div>

</div>
<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });
    });

   
    /*管理员-删除*/
    function member_del(obj,id){
        layer.confirm('您确认要删除吗？',function(index){
            //发异步删除数据
			$.ajax({
				url:"{:URL('guanli/delete')}",
				data:{"id":id},
				type:"post",
				dataType:'json',
				success:function(msg){
					if(msg.code==1){
                        layer.msg("删除成功！",{icon: 6},function () {
                            //获得frame索引
                            var index = parent.layer.getFrameIndex(window.name);
                            //关闭当前frame
                            parent.layer.close(index);
                            window.location.reload();//刷新父级窗口

                        });
                        return false;
					}else{
                        layer.msg("删除失败！",{icon: 6},function () {
                            //获得frame索引
                            var index = parent.layer.getFrameIndex(window.name);
                            //关闭当前frame
                            parent.layer.close(index);
                            window.location.reload();//刷新父级窗口

                        });
                        return false;
					}
				}
			})
             
        });
    }
    //管理员禁用
    function member_jin(obj,id){
        //发异步删除数据
        $.ajax({
            url:"{:URL('guanli/jin')}",
            data:{"id":id},
            type:"post",
            dataType:'json',
            success:function(msg){
                if(msg==1){
                    layer.msg("已禁用！",{icon: 6},function () {
                        //获得frame索引
                        var index = parent.layer.getFrameIndex(window.name);
                        //关闭当前frame
                        parent.layer.close(index);
                        window.location.reload();//刷新父级窗口
                    });
                    return false;
                }else{
                    layer.msg("禁用失败！",{icon: 6},function () {
                        //获得frame索引
                        var index = parent.layer.getFrameIndex(window.name);
                        //关闭当前frame
                        parent.layer.close(index);
                        window.location.reload();//刷新父级窗口
                    });
                    return false;
                }
            }
        })
        return false;
    }
    //管理员禁用
    function member_qi(obj,id){
        //发异步删除数据
        $.ajax({
            url:"{:URL('guanli/jin')}",
            data:{"id":id},
            type:"post",
            dataType:'json',
            success:function(msg){
                if(msg==1){
                    layer.msg("启用成功！",{icon: 6},function () {
                        //获得frame索引
                        var index = parent.layer.getFrameIndex(window.name);
                        //关闭当前frame
                        parent.layer.close(index);
                        window.location.reload();//刷新父级窗口

                    });
                    return false;
                }else{
                    layer.msg("禁用失败！",{icon: 6},function () {
                        //获得frame索引
                        var index = parent.layer.getFrameIndex(window.name);
                        //关闭当前frame
                        parent.layer.close(index);
                        window.location.reload();//刷新父级窗口

                    });
                    return false;
                }
            }
        })
    }

    /*管理员-修改*/
	function banner_edit(obj,zid){
				var url="{:URL('guanli/update')}?id="+zid;
				x_admin_show('修改用户',url);
		}

</script>

</body>

</html>